package com.neo.rabbit.direct;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.neo.rabbit.DirectRabbitMQConfig;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Component
public class DirectSender
{
    @Autowired
    private AmqpTemplate rabbitTemplate;
    
    /**
     * 往directExchange交换机中发送消息，使用direct.a.key作为路由规则
     * 
     * @see [类、类#方法、类#成员]
     */
    public void send()
    {
        String context = "hi, direct msg ";
        log.info("Sender : {}", context);
        this.rabbitTemplate.convertAndSend(DirectRabbitMQConfig.DIRECT_EXCHANGE, "direct.a.key", context);
    }
}
